//
//  HNWithdrawCashHistoryView.m
//  优学荟管理系统
//
//  Created by 星道 on 17/6/26.
//  Copyright © 2017年 星道三好. All rights reserved.
//

#import "HNWithdrawCashHistoryView.h"

@implementation HNWithdrawCashHistoryView
{
    IBOutlet UILabel *_SONO;
    IBOutlet UILabel *_Time;
    IBOutlet UILabel *_Status;
    IBOutlet UILabel *_Price;
    IBOutlet UILabel *_FishTime;

    IBOutlet UIView *_BackView;
    void (^_ClickCommit)(NSString *);
}

+ (instancetype)ConsumeSure_Model:(HNWithdrawCashHistoryModel *)Model ClickCommit:(void (^)(NSString *))ClickCommit
{
    return [[self alloc] initWithModel:Model ClickCommit:ClickCommit];
}




//初始化
- (instancetype)initWithModel:(HNWithdrawCashHistoryModel *)Model ClickCommit:(void (^)(NSString *))ClickCommit
{
    self = [[[NSBundle mainBundle] loadNibNamed:[HNWithdrawCashHistoryView description] owner:nil options:nil] lastObject];
    if (self) {

        [[UIApplication sharedApplication].keyWindow addSubview:self];

        self.frame = CGRectMake(0, 0, SCREEN_WIDTH, SCREENH_HEIGHT);

        _ClickCommit = ClickCommit;

        //textfield加上阴影效果
        [[_BackView layer] setMasksToBounds:YES];
        [[_BackView layer] setShadowOffset:CGSizeMake(1, 1)]; // 阴影的范围
        [[_BackView layer] setShadowRadius:3];                // 阴影扩散的范围控制
        [[_BackView layer] setShadowOpacity:1];               // 阴影透明度
        [[_BackView layer] setShadowColor:[UIColor blackColor].CGColor]; // 阴影的颜色
        [_BackView setClipsToBounds:NO];


        self.alpha = 0;

        // 界面传值
        [self SetupView_Model:Model];

        //弹出窗口
        [self Show];
    }
    return self;
}




/**
 界面传值
 */
- (void)SetupView_Model:(HNWithdrawCashHistoryModel *)Model
{
    // 订单号码
    _SONO.text = Model.withdrawNo;
    // 申请时间
    _Time.text = Model.withdrawTime;
    // 完成时间
    _FishTime.text = Model.withdrawFinishTime.length > 0 ? Model.withdrawFinishTime:@"-";
    //状态
    _Status.text = [self GetStrForIndex:[Model.withdrawFlag integerValue] Type:[Model.type integerValue] Num:[Model.num integerValue]];
    //价格
    _Price.text = [NSString stringWithFormat:@"%.2f",[Model.withdrawAmount doubleValue]];
}


/**
 提现状态 -1：未提现或暂不可提现 0：提现中，1：财务拒绝，2：财务同意，3：终审拒绝，4：终审同意，5：已结算 Type:0课程结算 1佣金金额
 当状态为-1时，判断Type的值，0显示未提现 1的话根据 num 值 ，2为未提现，1为暂不可提现
 */
- (NSString *)GetStrForIndex:(NSInteger)Index Type:(NSInteger)Type Num:(NSInteger)Num
{
    switch (Index)
    {
            //Index为-1
        case -1:
        {
            if (Type == 0)
            {
                return @"未提现";
            }
            else
            {
                if (Num == 2)
                {
                    return @"未提现";
                }
                else
                {
                    return @"暂不可提现";
                }
            }
        };break;
        case 0:return @"提现中";break;
        case 1:return @"财务拒绝";break;
        case 2:return @"财务同意";break;
        case 3:return @"终审拒绝";break;
        case 4:return @"终审同意";break;
        case 5:return @"已提现";break;
        default:return @"未知";break;
    }
}







/**
 显示自己
 */
- (void)Show {
    //动画展示
    [UIView animateWithDuration:0.3 animations:^{
        self.alpha = 1;
    }];
}



/**
 移除自己，并关闭界面
 */
- (IBAction)Close {

    [self endEditing:YES];

    //动画开始
    [UIView animateWithDuration:0.3 animations:^{
        self.alpha = 0;
    } completion:^(BOOL finished) {
        [self removeFromSuperview];
    }];
    
}

// 来源更多
- (IBAction)more:(UIButton *)sender {

    _ClickCommit ? _ClickCommit (_SONO.text):nil;
}






































#pragma mark --- 课程提现
+ (instancetype)ConsumeDrawalSure_Model:(ZYCurriculumWithdrawalModel *)Model ClickCommit:(void(^)(NSString *))ClickCommit{
    return [[self alloc] initWithDrawalModel:Model ClickCommit:ClickCommit];

}

//初始化
- (instancetype)initWithDrawalModel:(ZYCurriculumWithdrawalModel *)Model ClickCommit:(void (^)(NSString *))ClickCommit{
    self = [[[NSBundle mainBundle] loadNibNamed:[HNWithdrawCashHistoryView description] owner:nil options:nil] lastObject];
    if (self) {
        
        [[UIApplication sharedApplication].keyWindow addSubview:self];
        
        self.frame = CGRectMake(0, 0, SCREEN_WIDTH, SCREENH_HEIGHT);
        
        _ClickCommit = ClickCommit;
        
        //textfield加上阴影效果
        [[_BackView layer] setMasksToBounds:YES];
        [[_BackView layer] setShadowOffset:CGSizeMake(1, 1)]; // 阴影的范围
        [[_BackView layer] setShadowRadius:3];                // 阴影扩散的范围控制
        [[_BackView layer] setShadowOpacity:1];               // 阴影透明度
        [[_BackView layer] setShadowColor:[UIColor blackColor].CGColor]; // 阴影的颜色
        [_BackView setClipsToBounds:NO];

        
        self.alpha = 0;
        
        // 界面传值
        [self SetupDrawalView_Model:Model];
        
        //弹出窗口
        [self Show];
    }
    return self;
}

/**
 界面传值
 */
- (void)SetupDrawalView_Model:(ZYCurriculumWithdrawalModel *)Model{
    // 订单号码
    _SONO.text = Model.withdrawNo;
    // 申请时间
    _Time.text = Model.withdrawTime;
    // 完成时间
    _FishTime.text = Model.withdrawFinishTime.length > 0 ? Model.withdrawFinishTime:@"-";
    //状态
    _Status.text = [self GetStrForIndex:[Model.withdrawFlag integerValue] Type:[Model.type integerValue] Num:[Model.num integerValue]];
    //价格
    _Price.text = [NSString stringWithFormat:@"%.2f",[Model.withdrawAmount doubleValue]];
}



#pragma mark --- 套餐提现
+ (instancetype)ConsumeSure_SetModel:(ZYSetTheCuModel *)SetModel ClickCommit:(void (^)(NSString *))ClickCommit{
    return [[self alloc] initWithSetModel:SetModel ClickCommit:ClickCommit];
}



//初始化
- (instancetype)initWithSetModel:(ZYSetTheCuModel *)SetModel ClickCommit:(void (^)(NSString *))ClickCommit{
    self = [[[NSBundle mainBundle] loadNibNamed:[HNWithdrawCashHistoryView description] owner:nil options:nil] lastObject];
    if (self) {
        
        [[UIApplication sharedApplication].keyWindow addSubview:self];
        
        self.frame = CGRectMake(0, 0, SCREEN_WIDTH, SCREENH_HEIGHT);
        
        _ClickCommit = ClickCommit;
        
        //textfield加上阴影效果
        [[_BackView layer] setMasksToBounds:YES];
        [[_BackView layer] setShadowOffset:CGSizeMake(1, 1)]; // 阴影的范围
        [[_BackView layer] setShadowRadius:3];                // 阴影扩散的范围控制
        [[_BackView layer] setShadowOpacity:1];               // 阴影透明度
        [[_BackView layer] setShadowColor:[UIColor blackColor].CGColor]; // 阴影的颜色
        [_BackView setClipsToBounds:NO];
        

        self.alpha = 0;
        
        // 界面传值
        [self SetupView_SetModel:SetModel];
        
        //弹出窗口
        [self Show];
    }
    return self;
}

/**
 界面传值
 */
- (void)SetupView_SetModel:(ZYSetTheCuModel *)SetModel{
    // 订单号码
    _SONO.text = SetModel.withdrawNo;
    // 申请时间
    _Time.text = SetModel.withdrawTime;
    // 完成时间
    _FishTime.text = SetModel.withdrawTime.length > 0 ? SetModel.withdrawTime:@"-";
    //状态
    if (0 == [SetModel.withdrawFlag integerValue]) {
        _Status.text =@"提现中";
    }else if (1 == [SetModel.withdrawFlag integerValue]){
        _Status.text = @"财务拒绝";
    }else if (2 == [SetModel.withdrawFlag integerValue]){
       _Status.text = @"财务同意";
    }else if (3 == [SetModel.withdrawFlag integerValue]){
      _Status.text = @"终审拒绝";
    }else if (4 == [SetModel.withdrawFlag integerValue]){
        _Status.text = @"终审同意";
    }else if (5 == [SetModel.withdrawFlag integerValue]){
        _Status.text = @"已提现";
        
    }


    //价格
    _Price.text = [NSString stringWithFormat:@"%.2f",[SetModel.withdrawAmount doubleValue]];

}



#pragma mark --- 课时卡提现
+ (instancetype)ConsumeSure_SetClassCashModel:(ZYClassCardWithdrawalsModel *)SetModel ClickCommit:(void(^)(NSString *))ClickCommit{
      return [[self alloc] initWithSetClassCashModel:SetModel ClickCommit:ClickCommit];
}
//初始化
- (instancetype)initWithSetClassCashModel:(ZYClassCardWithdrawalsModel *)SetModel ClickCommit:(void (^)(NSString *))ClickCommit{
    self = [[[NSBundle mainBundle] loadNibNamed:[HNWithdrawCashHistoryView description] owner:nil options:nil] lastObject];
    if (self) {
        
        [[UIApplication sharedApplication].keyWindow addSubview:self];
        
        self.frame = CGRectMake(0, 0, SCREEN_WIDTH, SCREENH_HEIGHT);
        
        _ClickCommit = ClickCommit;
        
        //textfield加上阴影效果
        [[_BackView layer] setMasksToBounds:YES];
        [[_BackView layer] setShadowOffset:CGSizeMake(1, 1)]; // 阴影的范围
        [[_BackView layer] setShadowRadius:3];                // 阴影扩散的范围控制
        [[_BackView layer] setShadowOpacity:1];               // 阴影透明度
        [[_BackView layer] setShadowColor:[UIColor blackColor].CGColor]; // 阴影的颜色
        [_BackView setClipsToBounds:NO];
        

        self.alpha = 0;
        
        // 界面传值
        [self SetupView_SetClassCashModel:SetModel];
        
        //弹出窗口
        [self Show];
    }
    return self;
}
/**
 界面传值
 */
- (void)SetupView_SetClassCashModel:(ZYClassCardWithdrawalsModel *)SetModel{
    // 订单号码
    _SONO.text = SetModel.withdrawNo;
    // 申请时间
    _Time.text = SetModel.withdrawTime;
    // 完成时间
    _FishTime.text = SetModel.withdrawTime.length > 0 ? SetModel.withdrawTime:@"-";
    //状态
    if (0 == [SetModel.withdrawFlag integerValue]) {
        _Status.text =@"提现中";
    }else if (1 == [SetModel.withdrawFlag integerValue]){
        _Status.text = @"财务拒绝";
    }else if (2 == [SetModel.withdrawFlag integerValue]){
        _Status.text = @"财务同意";
    }else if (3 == [SetModel.withdrawFlag integerValue]){
        _Status.text = @"终审拒绝";
    }else if (4 == [SetModel.withdrawFlag integerValue]){
        _Status.text = @"终审同意";
    }else if (5 == [SetModel.withdrawFlag integerValue]){
        _Status.text = @"已提现";
        
    }
    
    
    //价格
    _Price.text = [NSString stringWithFormat:@"%.2f",[SetModel.withdrawAmount doubleValue]];
    
}













#pragma mark ---- 课程抵扣提现
+ (instancetype)ConsumeSure_SetDeductionCashModel:(ZYCurriculumDeductionModel *)SetModel ClickCommit:(void(^)(NSString *))ClickCommit{
     return [[self alloc] initWithSetDeductionCashModel:SetModel ClickCommit:ClickCommit];
}
//初始化
- (instancetype)initWithSetDeductionCashModel:(ZYCurriculumDeductionModel *)SetModel ClickCommit:(void (^)(NSString *))ClickCommit{
    self = [[[NSBundle mainBundle] loadNibNamed:[HNWithdrawCashHistoryView description] owner:nil options:nil] lastObject];
    if (self) {
        
        [[UIApplication sharedApplication].keyWindow addSubview:self];
        
        self.frame = CGRectMake(0, 0, SCREEN_WIDTH, SCREENH_HEIGHT);
        
        _ClickCommit = ClickCommit;
        
        //textfield加上阴影效果
        [[_BackView layer] setMasksToBounds:YES];
        [[_BackView layer] setShadowOffset:CGSizeMake(1, 1)]; // 阴影的范围
        [[_BackView layer] setShadowRadius:3];                // 阴影扩散的范围控制
        [[_BackView layer] setShadowOpacity:1];               // 阴影透明度
        [[_BackView layer] setShadowColor:[UIColor blackColor].CGColor]; // 阴影的颜色
        [_BackView setClipsToBounds:NO];
        

        
        self.alpha = 0;
        
        // 界面传值
        [self SetupView_SetDeductionsCashModel:SetModel];
        
        //弹出窗口
        [self Show];
    }
    return self;
}
/**
 界面传值
 */
- (void)SetupView_SetDeductionsCashModel:(ZYCurriculumDeductionModel *)SetModel{
    // 订单号码
    _SONO.text = SetModel.withdrawNo;
    // 申请时间
    _Time.text = SetModel.withdrawTime;
    // 完成时间
    _FishTime.text = SetModel.withdrawTime.length > 0 ? SetModel.withdrawTime:@"-";
    //状态
    if (0 == [SetModel.withdrawFlag integerValue]) {
        _Status.text =@"提现中";
    }else if (1 == [SetModel.withdrawFlag integerValue]){
        _Status.text = @"财务拒绝";
    }else if (2 == [SetModel.withdrawFlag integerValue]){
        _Status.text = @"财务同意";
    }else if (3 == [SetModel.withdrawFlag integerValue]){
        _Status.text = @"终审拒绝";
    }else if (4 == [SetModel.withdrawFlag integerValue]){
        _Status.text = @"终审同意";
    }else if (5 == [SetModel.withdrawFlag integerValue]){
        _Status.text = @"已提现";
        
    }
    
    
    //价格
    _Price.text = [NSString stringWithFormat:@"%.2f",[SetModel.withdrawAmount doubleValue]];
    
}


#pragma mark ----- 佣金提现
+ (instancetype)ConsumeSure_SetCashModel:(ZYCurriculumCashWithdrawalModel *)SetModel ClickCommit:(void(^)(NSString *))ClickCommit{
    return [[self alloc] initWithSetCashModel:SetModel ClickCommit:ClickCommit];
}

//初始化
- (instancetype)initWithSetCashModel:(ZYCurriculumCashWithdrawalModel *)SetModel ClickCommit:(void (^)(NSString *))ClickCommit
{
    self = [[[NSBundle mainBundle] loadNibNamed:[HNWithdrawCashHistoryView description] owner:nil options:nil] lastObject];
    if (self) {
        
        [[UIApplication sharedApplication].keyWindow addSubview:self];
        
        self.frame = CGRectMake(0, 0, SCREEN_WIDTH, SCREENH_HEIGHT);
        
        _ClickCommit = ClickCommit;
        
        //textfield加上阴影效果
        [[_BackView layer] setMasksToBounds:YES];
        [[_BackView layer] setShadowOffset:CGSizeMake(1, 1)]; // 阴影的范围
        [[_BackView layer] setShadowRadius:3];                // 阴影扩散的范围控制
        [[_BackView layer] setShadowOpacity:1];               // 阴影透明度
        [[_BackView layer] setShadowColor:[UIColor blackColor].CGColor]; // 阴影的颜色
        [_BackView setClipsToBounds:NO];
        

        
        self.alpha = 0;
        
        // 界面传值
        [self SetupView_SetCashModel:SetModel];
        
        //弹出窗口
        [self Show];
    }
    return self;
}
/**
 界面传值
 */
- (void)SetupView_SetCashModel:(ZYCurriculumCashWithdrawalModel *)SetModel{
    // 订单号码
    _SONO.text = SetModel.withdrawNo;
    // 申请时间
    _Time.text = SetModel.withdrawTime;
    // 完成时间
    _FishTime.text = SetModel.withdrawTime.length > 0 ? SetModel.withdrawTime:@"-";
    //状态
    if (0 == [SetModel.withdrawFlag integerValue]) {
        _Status.text =@"提现中";
    }else if (1 == [SetModel.withdrawFlag integerValue]){
        _Status.text = @"财务拒绝";
    }else if (2 == [SetModel.withdrawFlag integerValue]){
        _Status.text = @"财务同意";
    }else if (3 == [SetModel.withdrawFlag integerValue]){
        _Status.text = @"终审拒绝";
    }else if (4 == [SetModel.withdrawFlag integerValue]){
        _Status.text = @"终审同意";
    }else if (5 == [SetModel.withdrawFlag integerValue]){
        _Status.text = @"已提现";
        
    }
    
    
    //价格
    _Price.text = [NSString stringWithFormat:@"%.2f",[SetModel.withdrawAmount doubleValue]];
    
}



@end
